package zeus.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@Entity
public class Consumivel implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4339343073409373990L;
	
	public Consumivel(){
		
	}
	
	public Consumivel(double preco, TipoConsumivel tipoConsumivel, String descricao){
		this.preco = preco;
		this.tipoConsumivel = tipoConsumivel;
		this.descricao = descricao;
	}
	
	@Id
	@GeneratedValue
	private Long id;
	
	private double preco;
	
	@Enumerated(EnumType.STRING)
	private TipoConsumivel tipoConsumivel;
	
	private String descricao;
	
	@ManyToOne(cascade = CascadeType.ALL)
	private Quarto quarto;

	public double getPreco() {
		return preco;
	}

	public void setPreco(double preco) {
		this.preco = preco;
	}

	public TipoConsumivel getTipoConsumivel() {
		return tipoConsumivel;
	}

	public void setTipoConsumivel(TipoConsumivel tipoConsumivel) {
		this.tipoConsumivel = tipoConsumivel;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}
	
	@Override
	public String toString(){
		return descricao +" - "+ preco+"R$";
	}

	public Quarto getQuarto() {
		return quarto;
	}

	public void setQuarto(Quarto quarto) {
		this.quarto = quarto;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((descricao == null) ? 0 : descricao.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		long temp;
		temp = Double.doubleToLongBits(preco);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		result = prime * result + ((quarto == null) ? 0 : quarto.hashCode());
		result = prime * result
				+ ((tipoConsumivel == null) ? 0 : tipoConsumivel.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Consumivel other = (Consumivel) obj;
		if (descricao == null) {
			if (other.descricao != null)
				return false;
		} else if (!descricao.equals(other.descricao))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (Double.doubleToLongBits(preco) != Double
				.doubleToLongBits(other.preco))
			return false;
		if (quarto == null) {
			if (other.quarto != null)
				return false;
		} else if (!quarto.equals(other.quarto))
			return false;
		if (tipoConsumivel != other.tipoConsumivel)
			return false;
		return true;
	}

	
	
	
	
	
	
}
